﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CMS.Data.Classes;
using CMS.Data.Repositorios;

namespace App.UI.Auxiliares
{
    public class Metodos
    {
        /// <summary>
        /// Valida o login e retorna o usuário logado
        /// </summary>
        /// <returns></returns>
        public Usuario ValidarLogin()
        {
            Usuario usu = null;

            if (HttpContext.Current.Session["User"] != null && HttpContext.Current.Session["Password"] != null)
            {
                UsuarioRepository usuRepository = new UsuarioRepository();

                string email = HttpContext.Current.Session["User"].ToString();
                string senha = HttpContext.Current.Session["Password"].ToString();

                usu = usuRepository.SelectByEmailSenha(email, senha);
            }

            return usu;
        }


        
    }
}